package think.in.java.concurrency.PractiseOneMoreTime;

/**
 * Following the form of generics/Fibonacci.java,
 * create a task that produces a sequence of n Fibonacci numbers,
 * where n is provided to the constructor of the task.
 * Create a number of these tasks and drive them using threads
 */
public class Exec2ForFibonacci implements Runnable {


    public static void main(String[] args){
        Thread[] threads = new Thread[3];

        for(int i =0 ; i <3; i++){
            threads[i] = new Thread(new Exec2ForFibonacci());
            threads[i].start();
        }

    }

    @Override
    public void run() {
        IteratorFibonacci iteratorFibonacci = new IteratorFibonacci(20);
        for(Integer result : iteratorFibonacci){
            System.out.println(Thread.currentThread().getName()+":"+ result);
            Thread.yield();
        }

    }
}
